//
//  HRHomeViewController.m
//  心理FM
//
//  Created by rui on 7/9/15.
//  Copyright (c) 2015 loverforevercyr. All rights reserved.
//

#import "HRHomeViewController.h"

#import "Masonry.h"

@interface HRHomeViewController ()
/**
 *  在self.view上添加一个UIScrollView控件
 */
@property(weak, nonatomic) UIScrollView         *contentView;

@property(weak, nonatomic) UIImageView          *imageView;

@end

@implementation HRHomeViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor yellowColor];
    
    [self setUpScrollView];
//    
//    NSLog(@"contentView:%@", NSStringFromCGRect(self.contentView.frame));
//    NSLog(@"contentView.contentOffset:%@", NSStringFromCGPoint(self.contentView.contentOffset));
//    NSLog(@"contentView.contentInset:%@", NSStringFromUIEdgeInsets(self.contentView.contentInset));
//    NSLog(@"contentView.contentSize:%@", NSStringFromCGSize(self.contentView.contentSize));
//    NSLog(@"self.view:%@", NSStringFromCGRect(self.view.frame));
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)viewDidAppear:(BOOL)animated {
    [super viewDidAppear:animated];
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

#pragma mark - 懒加载
- (UIScrollView *)contentView {
    if (!_contentView) {
        // 创建一个UIScrollView控件对象
        UIScrollView *contentView = [[UIScrollView alloc] init];
        
        // 将其添加到self.view上
        [self.view addSubview:contentView];
        _contentView = contentView;
        contentView.backgroundColor = [UIColor redColor];
        contentView.bounces = NO;
        
        // 设置contentView的约束
        [contentView makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.view);
            make.left.equalTo(self.view);
            make.bottom.equalTo(self.view);
            make.right.equalTo(self.view);
        }];
    }
    return _contentView;
}

#pragma mark - 初始化相关
/**
 *  添加一个UIScrollView
 */
- (void)setUpScrollView {
//    UIScrollView *scrollView =
    [self contentView];
    
    UIImage *image = [UIImage imageNamed:@"高圆圆2"];
    UIImageView *imageView = [[UIImageView alloc] init];
    imageView.image = image;
    imageView.contentMode = UIViewContentModeScaleAspectFill;
//    imageView.clipsToBounds = YES;
    
    
    [self.contentView addSubview:imageView];
    _imageView = imageView;
    
    [imageView makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentView);
        make.right.equalTo(self.contentView);
        make.top.equalTo(self.contentView);
        make.bottom.equalTo(self.contentView);
        make.width.equalTo(self.view);
        make.height.equalTo(self.view);
    }];
}

@end
